﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>新增员工</title>
    <link rel="icon" type="image/png" href="/Source/assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="/Source/assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI" />
    <link rel="stylesheet" href="/Source/assets/css/amazeui.min.css" />
    <link rel="stylesheet" href="/Source/assets/css/admin.css">
    <script src="/Scripts/jquery-3.4.1.min.js"></script>
    <script src="/Source/layui/layui.all.js"></script>
    <script src="/Source/layui/layui.js"></script>
    <link href="/Source/layui/css/layui.css" rel="stylesheet" />
    <script>
        $(function () {
            $("#btnSubmit").click(function () {
                //账号
                var account = $("#txtAccount").val().trim();
                //姓名
                var realName = $("#txtName").val().trim();
                //性别
                var sex = $("#Sex").val();
                //出生日期
                var birthday = $("#txtBirthday").val().trim();
                //身份证
                var idcard = $("#txtIDCard").val().trim();
                //户籍地
                var address1 = $("#txtAddress1").val().trim();
                //现居住地
                var address2 = $("#txtAddress2").val().trim();
                //职位
                var positionId = $("#PositionId").val();
                //部门
                var departmentId = $("#departmentId").val();
                $.ajax({
                    url: "/Employee/Add",
                    type: "post",
                    data: {
                        "Account": account, "RealName": realName, "Sex": sex,
                        "Birthday": birthday, "IDCard": idcard, "Address1": address1,
                        "Address2": address2, "PositionId": positionId, "DepartmentId": departmentId
                    },
                    success: function (returnData) {
                        console.log(returnData);
                        if (returnData.Code == 1) {
                            layer.alert("录入信息成功！", 3000, function() {
                                layer.closeAll();
                            });
                           
                        }
                    }, error: function () {

                    }
                });
            });

        });

    </script>
</head>
<body>
    <div class="am-tab-panel am-fade am-active am-in" id="tab2">
        <form class="am-form">
            <div class="am-g am-margin-top">
                <div class="am-u-sm-2 am-text-right">
                    账号
                </div>
                <div class="am-u-sm-4">
                    <input type="text" class="am-input-sm" id="txtAccount">
                </div>
                <div class="am-u-sm-6"></div>
            </div>

            <div class="am-g am-margin-top">
                <div class="am-u-sm-2 am-text-right">
                    姓名
                </div>
                <div class="am-u-sm-4 col-end">
                    <input type="text" class="am-input-sm" id="txtName">
                </div>
                <div class="am-u-sm-6"></div>
            </div>

            <div class="am-g am-margin-top">
                <div class="am-u-sm-2 am-text-right">
                    性别
                </div>
                <div class="am-u-sm-10" style="width: 200px">
                    <select id="Sex">
                        <option value="true">男</option>
                        <option value="false">女</option>
                    </select>
                </div>
                <div class="am-u-sm-6"></div>
            </div>

            <div class="am-g am-margin-top">
                <div class="am-u-sm-2 am-text-right">
                    出生日期
                </div>
                <div class="am-u-sm-4">
                    <input type="text" class="am-form-field am-input-sm" placeholder="时间" id="txtBirthday">
                </div>
                <div class="am-u-sm-6"></div>
            </div>

            <div class="am-g am-margin-top-sm">
                <div class="am-u-sm-2 am-text-right">
                    身份证号
                </div>
                <div class="am-u-sm-10">
                    <input type="text" class="am-input-sm" id="txtIDCard">
                </div>
            </div>

            <div class="am-g am-margin-top">
                <div class="am-u-sm-2 am-text-right">
                    户籍地
                </div>
                <div class="am-u-sm-4 col-end">
                    <input type="text" class="am-input-sm" id="txtAddress1">
                </div>
                <div class="am-u-sm-6"></div>
            </div>

            <div class="am-g am-margin-top">
                <div class="am-u-sm-2 am-text-right">
                    现居住地
                </div>
                <div class="am-u-sm-4 col-end">
                    <input type="text" class="am-input-sm" id="txtAddress2">
                </div>
                <div class="am-u-sm-6"></div>
            </div>
            <div class="am-g am-margin-top">
                <div class="am-u-sm-2 am-text-right">
                    职位
                </div>
                <div class="am-u-sm-4 col-end">
                    <select id="PositionId">
                        <option value="0">--请选择--</option>
                        @{
                            
                            var positionList = new BLL.PositionManger().QueryList();
                            if (positionList.Count != 0)
                            {
                                foreach (var item in positionList)
                                {
                            <option value="@item.Id">@item.Name</option>
                                }
                            }
                            
                        }
                    </select>
                </div>
                <div class="am-u-sm-6"></div>
            </div>
            <div class="am-g am-margin-top">
                <div class="am-u-sm-2 am-text-right">
                    部门
                </div>
                <div class="am-u-sm-4 col-end">
                    <select id="departmentId">
                        <option value="0">--请选择--</option>
                        @{
                            var departmentList = new BLL.DepartmentManger().QueryList();
                            if (departmentList.Count != 0)
                            {
                                foreach (var item in departmentList)
                                {
                            <option value="@item.Id">@item.Name</option>
                                }
                            }
                        }
                    </select>
                </div>
                <div class="am-u-sm-6"></div>
            </div>
            <div class="am-margin">
                <button type="button" id="btnSubmit" class="am-btn am-btn-primary am-btn-xs">提交保存</button>
                <button type="reset" class="am-btn am-btn-primary am-btn-xs">放弃保存</button>
            </div>
        </form>
    </div>
</body>
</html>
